package com.test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Calc {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date date = simpleDateFormat.parse("2022-10-15 00:00");
        Date now = new Date();
        int day = (int) (now.getTime() - date.getTime()) / (1000 * 60 * 60 * 24); // 计算天数
        int countHour = (int) (now.getTime() - date.getTime()) / (1000 * 60 * 60); // 计算总共小时
        int hour = countHour - day * 24; // 不满一天的小时
        // 分钟，不为0则加一个小时
        int minute = (int) (now.getTime() - date.getTime()) / (1000 * 60) - countHour * 60;
        if (minute != 0) {
            hour++;
        }
        System.out.println(hour);
    }
}
